<?php if (!isset($v_sval)) exit; ?>
<?php
	$v_news_id = (isset($_REQUEST["hdn_news_id"])) ? $_REQUEST["hdn_news_id"] : 0;
	$v_news_category = NEWS_CATEGORY_USER_DIARY ;
	$v_news_time = (isset($_REQUEST["news_time"])) ? $_REQUEST["news_time"] : '';
	$v_news_content = (isset($_REQUEST["news_content"])) ? $_REQUEST["news_content"] : '';
	$v_account_id = $user_id;

	if ( $v_news_time ){
		$v_news_time = convertDatetoSQLDate($v_news_time);
	}
	
	if (!$v_news_id){
		$sql = 'INSERT INTO TB_NEWS (NEWS_CATEGORY, NEWS_TIME, NEWS_CONTENT, ACCOUNT_ID) 
				VALUES (
					"'.$v_news_category.'"
					,"'.$v_news_time.'"
					,"'.mysql_real_escape_string($v_news_content).'"
					,"'.$v_account_id.'"
				)';
		mysql_query ($sql) or die(mysql_error());
		$v_news_id = mysql_insert_id();
	}else{
		$sql = 'UPDATE TB_NEWS 
				SET 
					NEWS_TIME = "'.$v_news_time.'"
					, NEWS_CONTENT = "'.mysql_real_escape_string($v_news_content).'"
				WHERE NEWS_ID = "'.$v_news_id.'"
				';
		mysql_query ($sql) or die(mysql_error());
	}
	redir("?a=ACC&acc=USER&user=DIAR");
?>	
